package com.cmc.cloud.cmclink.doc.rpcservice.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import com.cmc.cloud.cmclink.doc.rpcservice.RouteTransfer;
import com.cmc.cloud.cmclink.mkt.route.RouteApi;
import com.cmc.cloud.cmclink.mkt.route.dto.ExtendRouteReqVO;
import com.cmc.cloud.cmclink.mkt.route.dto.RouteDetailV2VO;
import com.cmes.framework.common.pojo.CommonResult;

import lombok.extern.slf4j.Slf4j;

/**
 * 营销-费率 实现类
 *
 * @author dev89
 * @date 2025/08/14 10:53
 **/
@Service
@Validated
@Slf4j
public class RouteTransferImpl implements RouteTransfer {
    @Resource
    private RouteApi routeApi;

    @Override
    public Integer getTransportTime(ExtendRouteReqVO extendRouteReqVO) {
        CommonResult<RouteDetailV2VO> commonResult;
        try {
            commonResult = routeApi.queryExtendRoute(extendRouteReqVO);
        } catch (Exception e) {
            log.error("caught an exception on calForecastFreight", e);
            return 0;
        }
        if (commonResult == null || commonResult.getData() == null) {
            log.error("calForecastFreight response null");
            return 0;
        }
        return commonResult.getData().getTransportTime();
    }
}
